package com.it.octoo;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Profile;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

/**
 * <p>
 * 说明
 * </p>
 *
 * @author miaoxiao
 * @since 2019-12-20
 */
@Profile("!pro")
@Configuration
@EnableSwagger2
public class SwaggerConfig {

    /**
     * groupName 必须与gateway中routeId相同
     * @return
     */
    @Bean
    public Docket userApi(){
        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(apiInfo("缪霄", "", ""))
//                .groupName("用户中心").pathMapping("/")
//                .genericModelSubstitutes()
                .select()
                .apis(RequestHandlerSelectors.basePackage("com.it.octoo.ctrl"))
                .paths(PathSelectors.any())
                .build();
    }

    private ApiInfo apiInfo(String name, String url, String email){
        return new ApiInfoBuilder()
                .title("OCTOO接口文档")
                .description("用户中心接口文档")
                .termsOfServiceUrl("")
                .contact(new Contact(name, url, email))
                .version("2.0")
                .build();
    }
}
